home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / THINK C Digest / 1990 / 90-11 < prev    next >
Text File  |  1995-12-31  |  63KB  |  1,842 lines

  1. 
  2. Path: ucivax!gateway
  3. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  4. Subject: Bug in CBartender?
  5. Message-ID: <2499.9011071344@subnode.lfcs.ed.ac.uk>
  6. Newsgroups: fa.think-c
  7. Lines: 7
  8. Date: 7 Nov 90 17:51:00 GMT
  9.  
  10. I've just had a quick look at CBartender. It has a table mapping menu items
  11. to commands, and it uses SetHandleSize() to alter the size of the table,
  12. but doesn't check that an attempt to increase the size always succeeds (it
  13. might fail if the handle's storage is right next to a non-relocatable
  14. block). This looks rather nasty. Should I be worried?
  15.  
  16. Nick.
  17. 
  18. 
  19. Path: ucivax!gateway
  20. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  21. Subject: The CBartender thing...
  22. Message-ID: <3250.9011081118@subnode.lfcs.ed.ac.uk>
  23. Newsgroups: fa.think-c
  24. Lines: 21
  25. Date: 8 Nov 90 11:28:09 GMT
  26.  
  27. The jury seems to be out on this one (judging by the replies I've received
  28. - thanks, everybody).
  29.  
  30. The general concensus seems to be that SetHandleSize can relocate a handle
  31. past a nonrelocatable block to un-landlock it. I seem to recall that
  32. handles never move over fixed blocks, though. I'll have to check IM II to
  33. see if that's different for SetHandleSize.
  34.  
  35. If SetHandleSize fails due to the above, some respondents reckoned the
  36. memory manager would be asked to make room; but, if the fixed blocks don't
  37. go away, I don't see what good this will do. Another reply claimed that a
  38. failing SetHandleSize causes the Memory Manager to report an error. Maybe,
  39. but I seem to recall that the description of the SetHandleSize trap says
  40. that it should be checked for failure. My copy of IM II is at home
  41. (needless to say...)
  42.  
  43. I doubt this is going to be a big problem in practice, but it might just
  44. take something like: create a new window (WindowRec's can't be relocated)
  45. and then insert a new menu for it... *blam*.
  46.  
  47. Nick.
  48. 
  49. 
  50. Path: ucivax!gateway
  51. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  52. Subject: The CBartender thing...
  53. Message-ID: <9011081446.AA02848@chaos.cs.brandeis.edu>
  54. In-Reply-To: Nick Rothwell's message of 8 Nov 90 11:28:09 GMT <3250.9011081118@subnode.lfcs.ed.ac.uk>
  55. Newsgroups: fa.think-c
  56. Lines: 11
  57. Date: 8 Nov 90 14:48:58 GMT
  58.  
  59. If SetHandleSize fails (in CBartender::AddMenu()) for lack of memory,
  60. the CApplication's GrowZoneProc will be invoked.  Since we didn't say
  61. that we wanted to handle the memory failure ourselves (by using
  62. CApplication::RequestMemory()), the GrowZoneProc will put up a dialog
  63. and quit the program.  I think.
  64.  
  65.     -phil
  66. ----
  67.    Phil Shapiro                           Technical Support Analyst
  68.    Language Products Group                     Symantec Corporation
  69.         Internet: phils@chaos.cs.brandeis.edu
  70. 
  71. 
  72. Path: ucivax!gateway
  73. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  74. Subject: MIDI Manager programmers - anybody home?
  75. Message-ID: <7375.9011121101@subnode.lfcs.ed.ac.uk>
  76. Newsgroups: fa.think-c
  77. Lines: 28
  78. Date: 12 Nov 90 11:13:16 GMT
  79.  
  80. Well, it's been a couple of years since Apple announced the MIDI Manager,
  81. and well over a year since it's been available (does that mean Apple have
  82. been in court over it for that long? Oh well...). Given that the Macintosh
  83. is pretty much the US standard machine for MIDI programming (except in
  84. Europe where people buy machines that they can actually afford instead),
  85. and given that MIDI Manager is quite easily available and quite easy to
  86. work with, where are all the bits and pieces of shareware/freeware? I have
  87. seen exactly two in the last year - a simple channelising echo application,
  88. and MacMuse. Is nobody else using it? Is everyone else rolling their own
  89. serial port drivers (yuck!)?
  90.  
  91. So. I want to talk about MIDI Manager programming, if anyone else is
  92. interested. Last year I wrote a generic editor/librarian using it, and I'm
  93. just finishing a complete re-write using the THINK Class Library. It uses a
  94. big chunk of the MIDI Manager facilities; for example, to transmit a patch
  95. bank, it does buffering of its output and allows MIDI Manager to send the
  96. MIDI data asynchronously into the future (up to the capacity of the output
  97. buffer) using a WakeUp task - a lot more sexy than busy-loops and
  98. spin-waits.
  99.  
  100. I'll even offer to (gosh!) share the source code for all of this - but only
  101. if we get talking, OK? (last time I got large numbers of requests for the
  102. code and I have no idea if anybody did anything with it or what...) MIDI
  103. Manager is too important to be ignored, so let's get cooking.
  104.  
  105. Anybody got any up-to-date news on the court case?
  106.  
  107. Nick.
  108. 
  109. 
  110. Path: ucivax!gateway
  111. From: schabtac@spot.colorado.edu (SCHABTACH ADAM)
  112. Subject: (none)
  113. Message-ID: <9011130617.AA25220@spot.Colorado.EDU>
  114. Newsgroups: fa.think-c
  115. Lines: 40
  116. Date: 13 Nov 90 06:17:20 GMT
  117.  
  118. Subject: Re: MIDI Manager programmers - anybody home?
  119.  
  120.  
  121. >work with, where are all the bits and pieces of shareware/freeware? I have
  122. >seen exactly two in the last year - a simple channelising echo application,
  123. >and MacMuse.
  124.  
  125. I ran across a third recently -- a Mac implementation of KeyFrets, that
  126. program originally written on a C-64 to make a MIDI keyboard act a
  127. bit like a guitar.
  128.  
  129. >So. I want to talk about MIDI Manager programming, if anyone else is
  130. >interested.
  131.  
  132. I'm interested (Nick, you probably already guessed that).
  133.  
  134. >I'll even offer to (gosh!) share the source code for all of this - but only
  135. >if we get talking, OK? (last time I got large numbers of requests for the
  136. >code and I have no idea if anybody did anything with it or what...) MIDI
  137. >Manager is too important to be ignored, so let's get cooking.
  138.  
  139. Well, I still keep a printed version of your source code and refer to it
  140. when I start messing with the MIDI Manager. That code and the arpeggiator
  141. program that comes with the MM is how I learned enough to write MacMuse.
  142. (BTW, you shouldn't feel too bad about not hearing from people who
  143. requested your code -- I sent about a dozen copies of MacMuse to people
  144. who asked for it, and got *one* response from someone saying they actually
  145. got it up and running, and gave it more than a few minutes' attention.)
  146.  
  147. >Anybody got any up-to-date news on the court case?
  148.  
  149. As of this issue of MacWeek, it's still being negotiated. :-( Apparently
  150. Apple Computer is trying to get Apple Corps to reliquish their copyright
  151. in some European countries, for reasons they won't disclose.
  152.  
  153. I've heard that v2.0 of the MIDI Mgr. is about to be released, or has
  154. been already. Anyone know about this?
  155.  
  156. --Adam
  157.  
  158. 
  159. 
  160. Path: ucivax!gateway
  161. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  162. Subject: MIDI Manager 2.0
  163. Message-ID: <8354.9011131421@subnode.lfcs.ed.ac.uk>
  164. Newsgroups: fa.think-c
  165. Lines: 45
  166. Date: 13 Nov 90 14:46:56 GMT
  167.  
  168. >Well, I still keep a printed version of your source code and refer to it
  169. >when I start messing with the MIDI Manager. That code and the arpeggiator
  170. >program that comes with the MM is how I learned enough to write MacMuse.
  171.  
  172. I'm currently rewriting my MIDI Driving code to eliminate the spin-waiting
  173. that I was using to space out the transmission of SysEx packets. The
  174. problem is that response to the user when selecting patches should be very
  175. fast, even if the packets have to be staggered for output. I can't use MIDI
  176. Manager's timestamping directly - sending packets with future timestamps
  177. would be OK, *except* that I do realtime echoing of MIDI channel data as
  178. well, and I don't want interference with outgoing continuation packets
  179. stamped to coincide with it. Also, there's no *proper* way of testing the
  180. destination buffer (there may be more than one) for capacity - you have to
  181. transmit and trust it, guessing a reasonable delay time. So, transmitting
  182. an entire patch bank using MIDI Manager's send-ahead will almost certainly
  183. fail. What I do now is queue the packets for output in a circular buffer,
  184. and then use a WakeUp task to actually send them out, in the same way the
  185. MIDIArp demo schedules itself WakeUp tasks to do the arpeggiation (but
  186. without sending anything into the future, which MIDIArp does).
  187.  
  188. >(BTW, you shouldn't feel too bad about not hearing from people who
  189. >requested your code -- I sent about a dozen copies of MacMuse to people
  190. >who asked for it, and got *one* response from someone saying they actually
  191. >got it up and running, and gave it more than a few minutes' attention.)
  192.  
  193. Aw, I got it up and running as well, but haven't gotten around to puzzling
  194. out what it actually does yet...! I may start using it as a test
  195. application to hammer my MIDI echoing routines. After that, I'll run
  196. Performer through them and try some fast sequencing...
  197.  
  198. I'll send out my code to anybody who's interested as soon as I've made sure
  199. it's solid. At the moment it hangs periodically while trying to clear the
  200. output buffers - presumably some critical section problem somewhere causing
  201. the WakeUp task to terminate. Right now, I have what must be the only MIDI
  202. librarian which can actually load a synthesiser while unloading from
  203. another one...
  204.  
  205. >I've heard that v2.0 of the MIDI Mgr. is about to be released, or has
  206. >been already. Anyone know about this?
  207.  
  208. I've been told that in a roundabout way by a contact at MOTU. I've asked a
  209. developer contact of mine to chase up APDA here in the UK to find out.
  210. ("MIDI Manager? What's that?") More to follow when I hear something.
  211.  
  212. Nick.
  213. 
  214. 
  215. Path: ucivax!gateway
  216. From: schabtac@spot.colorado.edu (SCHABTACH ADAM)
  217. Subject: Graphic controls?
  218. Message-ID: <9011131606.AA01876@spot.Colorado.EDU>
  219. Newsgroups: fa.think-c
  220. Lines: 11
  221. Date: 13 Nov 90 16:10:36 GMT
  222.  
  223.  
  224. I'm thinking about a project that will involve nonstandard scroll bar-like
  225. controls. (Why? Well, they look nifty, and I'm trying to emulate a piece
  226. of hardware.) What I want is basically something like the Volume slider in
  227. the Control Panel, but I need more resolution (i.e. a range of 0-127 rather
  228. than 0-7). I imagine I could write it myself, but it would save some valuable
  229. time if I could use someone else's code. Has anyone written or seen a class
  230. to do this?
  231.  
  232. Thanks,
  233. --Adam
  234. 
  235. 
  236. Path: ucivax!gateway
  237. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  238. Subject: MIDI Manager
  239. Message-ID: <8450.9011131629@subnode.lfcs.ed.ac.uk>
  240. Newsgroups: fa.think-c
  241. Lines: 6
  242. Date: 13 Nov 90 18:47:53 GMT
  243.  
  244. I've just been told that...
  245.  
  246. >    The word from APDA in the US is that Midi Manager 2.0 will be
  247. >released later this month.
  248.  
  249. Nick.
  250. 
  251. 
  252. Path: ucivax!gateway
  253. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  254. Subject: Graphic controls?
  255. Message-ID: <9011131919.AA08094@chaos.cs.brandeis.edu>
  256. In-Reply-To: SCHABTACH ADAM's message of 13 Nov 90 16:10:36 GMT <9011131606.AA01876@spot.Colorado.EDU>
  257. Newsgroups: fa.think-c
  258. Lines: 8
  259. Date: 13 Nov 90 19:19:33 GMT
  260.  
  261. Check out the article in August 1990 MacTutor (vol 6 no 8).  There's
  262. an article in there that describes writing a class for a meter-type
  263. control.  The control has a numeric readout that can be typed into,
  264. and the arrows automatically speed up after a certain amount of time.
  265. Even if this isn't what you're looking for, it should give you a head
  266. start.
  267.  
  268.     -phil
  269. 
  270. 
  271. Path: ucivax!gateway
  272. From: meric@portia.stanford.edu
  273. Subject: (none)
  274. Message-ID: <9011142049.AA02366@bianca.stanford.edu>
  275. Newsgroups: fa.think-c
  276. Lines: 2
  277. Date: 14 Nov 90 20:50:27 GMT
  278.  
  279.  
  280.  
  281. 
  282. 
  283. Path: ucivax!gateway
  284. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  285. Subject: MIDI Manager question (yup, me again...)
  286. Message-ID: <10277.9011151632@subnode.lfcs.ed.ac.uk>
  287. Newsgroups: fa.think-c
  288. Lines: 18
  289. Date: 15 Nov 90 17:34:47 GMT
  290.  
  291. Hi there. Me again, with a MIDI Manager question.
  292.  
  293. The MIDIWakeUp() call (which lets you attach a routine to a periodic or
  294. one-time time advance on a time port) - can you have more than one attached
  295. to a time port at once? I'm inclined to doubt it (where would MM allocate
  296. the space for the information, given that MIDIWakeUp() can be called at
  297. interrupt) - but, the documentation doesn't give anything away, and the
  298. MIDIArp demo program explicitly cancels WakeUp tasks even if they're
  299. non-periodic, one-time ones.
  300.  
  301. I've had problems which might be associated with the way that I happily
  302. call MIDIWakeUp() on a time port regardless of whether any wake-up routine
  303. is queued or not, expecting any outstanding one to be cancelled. If only
  304. one can be queued at a time, there's no problem, but...
  305.  
  306. Anybody have any clues?
  307.  
  308. Nick.
  309. 
  310. 
  311. Path: ucivax!gateway
  312. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  313. Subject: Bugs in CPicture?
  314. Message-ID: <15082.9011191143@subnode.lfcs.ed.ac.uk>
  315. Newsgroups: fa.think-c
  316. Lines: 6
  317. Date: 19 Nov 90 13:41:13 GMT
  318.  
  319. I've had the TCL class CPicture bomb on me. I had a quick look at the
  320. source, and its Dispose() method always calls KillPicture(). Inside Mac
  321. says that ReleaseResource() should be used for resource-based pictures
  322. (which I was using). Is CPicture out of line, or is it me?
  323.  
  324. Nick.
  325. 
  326. 
  327. Path: ucivax!gateway
  328. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  329. Subject: Bugs in CPicture?
  330. Message-ID: <9011191551.AA26220@chaos.cs.brandeis.edu>
  331. In-Reply-To: Nick Rothwell's message of 19 Nov 90 13:41:13 GMT <15082.9011191143@subnode.lfcs.ed.ac.uk>
  332. Newsgroups: fa.think-c
  333. Lines: 17
  334. Date: 19 Nov 90 15:57:15 GMT
  335.  
  336. You are entirely correct, CPicture is buggy.  Currently, there is no
  337. fix for it.  If you are constructing a picture on the fly (using
  338. CPicture::SetMacPicture()), then the code will work as it stands.  If
  339. you are using a resource file, you should override CPicture::Dispose,
  340. so it just uses ReleaseResource().  This is how I would write it:
  341.  
  342. void    RsrcCPicture::Dispose()
  343. {
  344.     ReleaseResource(macPicture);
  345.     CPanorama::Dispose();         /* this can't be done in Pascal! */
  346. }
  347.  
  348. The second line is a direct superclass call.  It should be avoided
  349. whenever possible, but here it is necessary (unless we modify the
  350. TCL).
  351.  
  352.     -phil
  353. 
  354. 
  355. Path: ucivax!gateway
  356. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  357. Subject: About-Box Blues
  358. Message-ID: <15287.9011191435@subnode.lfcs.ed.ac.uk>
  359. Newsgroups: fa.think-c
  360. Lines: 22
  361. Date: 19 Nov 90 19:34:02 GMT
  362.  
  363. How are y'all doing your about-boxes? Are there any interface guidelines
  364. about this?
  365.  
  366. I wanted something a little sexier than the usual modal dialog. In which
  367. case, it becomes important to figure out whether to grab control of the Mac
  368. for the duration of the about-box, or what...
  369.  
  370. For the time being, I've implemented a similar one to the Art Class demo -
  371. i.e., create a director and window, bring it to the front, draw into it
  372. directly, and spin-wait until a key or mouse event (I tried a CPicture, but
  373. think these are buggy - see previous posting - so I might use a sub-class
  374. to avoid the bug). The problem I've had is that the underlying document
  375. window gets partially deactivated after the about-box has gone, and the
  376. mouse coordinate environment seems to get nuked for window clicks. Art
  377. Class seems to get this right (although Desk Accessories confuse it a
  378. little), so I'll give this a closer look.
  379.  
  380. Any reason why I *shouldn't * implement a spin-wait about-box?
  381.  
  382. If it's good enough for THINK C, it's good enough for me...
  383.  
  384. Nick.
  385. 
  386. 
  387. Path: ucivax!gateway
  388. From: mwg@med.pitt.edu ("Michael W. Groff")
  389. Subject: include me in the mailing list
  390. Message-ID: <9011200206.AA22263@mercury.med.pitt.edu>
  391. Newsgroups: fa.think-c
  392. Lines: 3
  393. Date: 20 Nov 90 02:08:31 GMT
  394.  
  395. Please add me to the think-c mailing list.
  396. Thanks,
  397. mike
  398. 
  399. 
  400. Path: ucivax!gateway
  401. From: torrie@neon.stanford.edu (Evan James Torrie)
  402. Subject: Think C mailing list
  403. Message-ID: <9011200610.AA18232@Neon.Stanford.EDU>
  404. Newsgroups: fa.think-c
  405. Lines: 7
  406. Date: 20 Nov 90 06:12:57 GMT
  407.  
  408. Can I subscribe to this list?
  409.  
  410.  
  411. --
  412. ------------------------------------------------------------------------------
  413. Evan Torrie.  Stanford University, Class of 199?       torrie@cs.stanford.edu
  414. Fame, fame, fame...  What's it good for?  Ab-so-lute-ly nothing
  415. 
  416. 
  417. Path: ucivax!gateway
  418. From: fjlim@garnet.berkeley.edu
  419. Subject: CPicture Bugs
  420. Message-ID: <9011200730.AA19783@garnet.berkeley.edu>
  421. Newsgroups: fa.think-c
  422. Lines: 20
  423. Date: 20 Nov 90 07:34:30 GMT
  424.  
  425. The buggy Dispose() method was added by the infamous 4.0.2 THINK C update.
  426. Previously, CPicture had no Dispose() method, and this is still the case
  427. with the current Pascal version.
  428.  
  429. The solution is not straightforward. The reason that the Dispose() method
  430. was left out in the original version was to avoid killing or releasing
  431. a PICT that might be used in another window. It was not an oversight. A
  432. common use for CPicture is to have a header picture at the top of each
  433. window (perhaps a company logo). Closing one window should not kill (or
  434. release the picture), since that same picture is used in the other open
  435. windows. I couldn't come up with a clean solution for dealing with a
  436. resource that could have multiple users. Some sort a reference count is
  437. needed so that the resource is released only when there are no more
  438. references to it. I opted for the simple, memory wasteful, solution of
  439. not releasing it at all. Apparently, Symantec thought that not killing
  440. (or releasing) the picHandle upon disposing of the CPicture was an oversight,
  441. so they "corrected" it in the 4.0.2 update. My mistake was not documenting
  442. the reason for the omission.
  443.  
  444. -- Greg
  445. 
  446. 
  447. Path: ucivax!gateway
  448. From: beausol@blake.u.washington.edu (Ray Beausoleil)
  449. Subject: THINK C Mailing List
  450. Message-ID: <9011201427.AA04501@blake.u.washington.edu>
  451. Newsgroups: fa.think-c
  452. Lines: 8
  453. Date: 20 Nov 90 14:31:51 GMT
  454.  
  455.  
  456. I just read a note on comp.sys.mac.programmer that I could join a THINK C
  457. mailing list at this address. Is this true? If so, how do I sign up?
  458.  
  459. Thanks,
  460.  
  461. Ray Beausoleil
  462. beausol@blake.u.washington.edu
  463. 
  464. 
  465. Path: ucivax!gateway
  466. From: c90davby@odalix.ida.liu.se (David Byers)
  467. Subject: Please add me to the mailinglist
  468. Message-ID: <9011201940.AA18705@odal18.ida.liu.se>
  469. Newsgroups: fa.think-c
  470. Lines: 5
  471. Date: 20 Nov 90 19:46:07 GMT
  472.  
  473. Please add me to the THINK C mailinglist.
  474.  
  475. David Byers
  476.  
  477. c90davby@odalix.ida.liu.se
  478. 
  479. 
  480. Path: ucivax!gateway
  481. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  482. Subject: About-box Blues
  483. Message-ID: <16544.9011201129@subnode.lfcs.ed.ac.uk>
  484. Newsgroups: fa.think-c
  485. Lines: 23
  486. Date: 20 Nov 90 20:51:41 GMT
  487.  
  488. Thanks to the folks who replied to me about this (and also about the
  489. CPicture bug).
  490.  
  491. Regarding the About-box - using the TCL as-is wasn't good enough, since I
  492. wanted to throw up the about-box when my application started and get rid of
  493. it when coming into the event loop (yup, even on my SE/30, my application
  494. is big and complicated enough to make this a reasonable delay). The TCL
  495. wouldn't draw the picture until a refresh. So, my trick was to create a
  496. CDirector, allocate a window, bring the window to the front, and draw
  497. directly into it - a bit easier than using a (fixed) CPicture.
  498.  
  499. The problem I was having was that doing the about-box by creating a
  500. CDirector, selecting its window, spin-waiting until Button() or key-click,
  501. and then nuking the director, wasn't working. The underlying document
  502. window would then deactivate and go into an inconsistent state. Finally, I
  503. twigged what Greg Dow did in the Art Class - use the floating window
  504. desktop, and make the about-box a floating window, to avoid screwing the
  505. other windows. Nice one. Problem fixed.
  506.  
  507. The spin-wait code is just lifted from Art Class (however, it exits when
  508. the command or control key is hit - I think this is wrong...)
  509.  
  510. Nick.
  511. 
  512. 
  513. Path: ucivax!gateway
  514. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  515. Subject: MIDI Manager problem - found it...
  516. Message-ID: <16750.9011201451@subnode.lfcs.ed.ac.uk>
  517. Newsgroups: fa.think-c
  518. Lines: 38
  519. Date: 20 Nov 90 20:51:53 GMT
  520.  
  521. [I didn't see this message come past on the list (although I saw my other
  522. two),
  523.  so perhaps it got lost. Apologies if you see it twice.
  524. ]
  525.  
  526. Think I found my MIDI Manager timing problem. This is an interesting one:
  527.  
  528. I have an output buffer for MIDI packets, and it's serviced by an interrupt
  529. routine, so that the application can respond immediately to the user while
  530. queueing packets for transmission some time into the future. When a packet
  531. is queued, I had a call something like the following:
  532.  
  533.    MIDIWakeUp(refNum, MIDIGetCurTime() + 1, 0, &myTimeHook);
  534.  
  535. That schedules a call to myTimeHook 1 tick (1 msec, in fact) into the
  536. future, cancelling any existing schedule. The "+ 1" makes sure that the
  537. hook isn't scheduled exactly at the present time (in which case, it
  538. wouldn't get called, unless the time was rolled backwards....).
  539.  
  540. I was getting periodic hangups on my SE/30, and repeatable hangups on a Mac
  541. Plus. It then occurred to me that the above was unsafe - what if the clock
  542. ticks between the call to GetCurTime() and WakeUp()? So, I turned it into a
  543. "+ 2", assuming that any Mac should be able to assemble arguments to a
  544. procedure in at most a millisecond...!
  545.  
  546. Problem fixed on the SE/30, *except* when running the debugger...
  547.  
  548. I've now rewritten this part of the code in a different way, and it seems
  549. solid on the SE/30 and the Plus.
  550.  
  551. The lesson here: check your critical sections and timing conditions
  552. carefully (always the case with interrupt programming), *and* : expect the
  553. debugger to grab control from you for milliseconds at a time.
  554.  
  555. Can somebody in the know actually confirm that the debugger is doing this?
  556. If not, the problem is/was more complex that I guessed...
  557.  
  558. Nick.
  559. 
  560. 
  561. Path: ucivax!gateway
  562. From: gar@lingua.cltr.uq.oz.au (Greg Restall)
  563. Subject: Think C Mailing list???
  564. Message-ID: <9011202103.AA24975@lingua.cltr.uq.OZ.AU>
  565. Newsgroups: fa.think-c
  566. Lines: 7
  567. Date: 20 Nov 90 21:07:08 GMT
  568.  
  569.  
  570. I heard that it was possible to get on a Think-C mailing list
  571. via this address.  Is this correct?  If so, what do I do?  Anyway,
  572. jut to make sure, mu address is gar@lingua.cltr.uq.oz.au -- Thanks
  573. a bunch.
  574.  
  575. Greg Restall.
  576. 
  577. 
  578. Path: ucivax!gateway
  579. From: idowell@BBN.COM
  580. Subject: request
  581. Message-ID: <9011201340.aa16176@ICS.UCI.EDU>
  582. Newsgroups: fa.think-c
  583. Lines: 5
  584. Date: 20 Nov 90 21:42:42 GMT
  585.  
  586. please add me to the think c mailing list.
  587. sorry if i sent this to the wrong place.
  588.  
  589. Ian Dowell
  590. idowell@bbn.com
  591. 
  592. 
  593. Path: ucivax!gateway
  594. From: wln@cunixb.cc.columbia.edu (William L Nussbaum)
  595. Subject: Mailing List
  596. Message-ID: <9011202243.AA22370@cunixb.cc.columbia.edu>
  597. Newsgroups: fa.think-c
  598. Lines: 1
  599. Date: 20 Nov 90 22:43:58 GMT
  600.  
  601. help
  602. 
  603. 
  604. Path: ucivax!gateway
  605. From: schorsch@oxy.edu (Brent William Schorsch)
  606. Subject: I would like to be on your mailing list
  607. Message-ID: <127696@tiger.oxy.edu>
  608. Newsgroups: fa.think-c
  609. Lines: 2
  610. Date: 21 Nov 90 08:04:18 GMT
  611.  
  612. I understand that you have a mailing list (copm.sys.mac.programmer 11/19)
  613. please add me to the list
  614. 
  615. 
  616. Path: ucivax!gateway
  617. From: pvowles@comec.ec.uwa.oz.au (Paul Vowles)
  618. Subject: Interfacing to other languages
  619. Message-ID: <9011210300.aa05169@ICS.UCI.EDU>
  620. Newsgroups: fa.think-c
  621. Lines: 11
  622. Date: 21 Nov 90 11:01:04 GMT
  623.  
  624.  
  625. I need to buy a C compiler for the Mac ... but it must be able to interface
  626. to AbSoft Fortran (by order of my Boss). Does Think-C provide such an
  627. interface ?? What is the best/most cost effective C compiler for this ??
  628.  
  629.                         Thanks
  630.  
  631.                         Paul Vowles
  632.  
  633.                         pvowles@comec.ec.uwa.oz.au
  634.  
  635. 
  636. 
  637. Path: ucivax!gateway
  638. From: emmayche@dhw68k.cts.COM (Mark Hartman)
  639. Subject: Please add me to mailing list
  640. Message-ID: <9011210145.AA19000@dhw68k.cts.com>
  641. Newsgroups: fa.think-c
  642. Lines: 7
  643. Date: 21 Nov 90 12:36:23 GMT
  644.  
  645. Hi there:
  646.  
  647. I hope I'm going about this in the right way - I'd like to be added to the
  648. THINK C mailing list.
  649.  
  650. Thanks.
  651.  
  652. 
  653. 
  654. Path: ucivax!gateway
  655. From: MPRADHAN@f.adelaide.edu.au
  656. Subject: Please add me to the list
  657. Message-ID: <901122003508.1e11@F.ADELAIDE.EDU.AU>
  658. Newsgroups: fa.think-c
  659. Lines: 16
  660. Date: 21 Nov 90 14:07:21 GMT
  661. X-Vmsmail-To: SMTP%"think-c@ics.uci.edu"
  662.  
  663.  
  664.  Hello,
  665.  
  666.  Could you please add me to your Think C mailing list.
  667.  
  668.  Thanks in advance.
  669.  
  670.  Regards,
  671.  Malcolm
  672.  
  673. _________________________________________________________________
  674.     Malcolm Pradhan                               _--_|\
  675.     Medical Informatics, Faculty of Medicine     /      \
  676.     University of Adelaide, South Australia      \_.--._/
  677.     InterNet: mpradhan@f.adelaide.edu.au               v
  678.     Fax: + 618 338 2108
  679. 
  680. 
  681. Path: ucivax!gateway
  682. From: kishon-amir@cs.yale.edu (Amir Kishon)
  683. Subject: Text processing
  684. Full-Name: Amir Kishon
  685. Message-ID: <9011211648.AA09272@NEBULA.SYSTEMSZ.CS.YALE.EDU>
  686. Newsgroups: fa.think-c
  687. Lines: 14
  688. Date: 21 Nov 90 16:49:03 GMT
  689.  
  690. I am looking for some TCclasses/sample code/ideas about implementing
  691. TextEdit like procedures that do not have the Mac-TextEdit limitations
  692. (i.e.  are not limited to 32K characters, have better performance
  693. etc.). Actually any pointers about implementing text processors in
  694. think-c would be greatly appreciated.  I already know about two
  695. commercial packages that do exactly that - the prepare() magazine and
  696. a Canadian company (which I forgot its name) packages. Unfortunately
  697. they cost not a trivial amount of $$$.
  698.  
  699. Thanks,
  700.  
  701. -amir
  702.  
  703.  
  704. 
  705. 
  706. Path: ucivax!gateway
  707. From: cohen@excalibur.itd.nrl.navy.MIL (Neil Cohen)
  708. Subject: ANSI Library problem
  709. Message-ID: <9011211745.AA12111@constellation.arpa>
  710. Newsgroups: fa.think-c
  711. Lines: 34
  712. Date: 21 Nov 90 17:50:04 GMT
  713.  
  714. Hi,
  715.  
  716. I'm relatively new to programming on the Mac. We recently purchased
  717. Think C 4.0, and I'm running on a Mac IIfx.
  718.  
  719. I ported a small program from my Unix system which builds and scans
  720. a directed graph. The program was building lots of trees, adding and
  721. discarding nodes as it worked its way through the graph. I found that
  722. I was running out of memory. A short test program (discarded, but I
  723. can redo it, it was only about 10 lines of code) showed that once
  724. memory was 'malloc'ed, then 'free'd, the next call to malloc did not
  725. re-acquire the same memory (all mallocs in my pgm were for the same size
  726. structure). I changed the mallocs to 'NewPtr', and the memory
  727. leak went away.
  728.  
  729. Is this a known problem? How often (if ever) is the ANSI library updated?
  730.  
  731. I'm also having some serious problems with fread/fwrite in a different program.
  732. Are there any known problems with those routines?
  733. I will finish documenting my trouble and will be asking for help
  734. on it later today or tomorrow.
  735.  
  736. Thanks,
  737.  
  738. nbc
  739.  
  740. NAME:   Neil B. Cohen (Tracor Applied Sciences)
  741. PHONE:  703-444-4610
  742. DOMAIN: nbc@excalibur.itd.nrl.navy.mil
  743. *************************************************************
  744. * Murphy's Philosophy: Smile - tomorrow will be worse...    *
  745. *                                                           *
  746. * O'Tooles Commentary: Murphy was an optimist!              *
  747. *************************************************************
  748. 
  749. 
  750. Path: ucivax!gateway
  751. From: nagel@ICS.UCI.EDU (Mark Nagel)
  752. Subject: ARCHIVE: NBP sample code
  753. Message-ID: <27705.659213900@ics.uci.edu>
  754. Newsgroups: fa.think-c
  755. Reply-To: nagel@ICS.UCI.EDU
  756. Organization: University of California, Irvine - Dept of ICS
  757. Lines: 19
  758. Date: 21 Nov 90 19:01:42 GMT
  759. Phone: (714) 856-5039
  760.  
  761. This is a silly little example of how to use the Inside Mac V
  762. (preferred) Appletalk routines, specifically NBP. It conforms
  763. to nobody's interface guidelines.
  764.  
  765. the program (I hesitate to even call it that) looks up all names
  766. not associated with the node on which it is run, and prints them
  767. to stdout. Known bugs include a propensity to hang when the names
  768. table is inconsistent (name duplication) and a failure of the
  769. SetSelfSend function to, well, SetSelfsend. Suggestions welcome.
  770.  
  771. Since the documentation in IM is, to say the least, confusing,
  772. and since I've often seen requests for this type of thing in
  773. CSMP and CSMC, I think this should help some people out.
  774.  
  775. A better version will be soon forthcoming,
  776. Source is Think-C 4.02
  777. -Rens Troost.
  778.  
  779. [saved as: /mac/think-c/examples/nbp_sample_code.hqx]
  780. 
  781. 
  782. Path: ucivax!gateway
  783. From: cohen@excalibur.itd.nrl.navy.MIL (Neil Cohen)
  784. Subject: Problems with fread/fwrite...?
  785. Message-ID: <9011211920.AA12292@constellation.arpa>
  786. Newsgroups: fa.think-c
  787. Lines: 167
  788. Date: 21 Nov 90 19:22:19 GMT
  789.  
  790. Hi,
  791.  
  792. Enclosed are 2 programs that are giving me fits. I'd be much obliged
  793. if someone can point out what I'm doing wrong, or whether I've run into
  794. a bug in Think C 4.0. For what it is worth, this code runs properly
  795. on my U*ix box.
  796.  
  797. The first program writes a binary file with (ANSI) fwrite(). The binary
  798. records are 16 (4 byte) words long and contain the following pattern:
  799.  
  800. 0x00000000  0x01010101  0x02020202  0x03030303
  801. 0x04040404  0x05050505  0x06060606  0x07070707
  802. 0x08080808  0x09090909  0x0a0a0a0a  0x0b0b0b0b
  803. 0x0c0c0c0c  0x0d0d0d0d  0x0e0e0e0e  0x0f0f0f0f
  804.  
  805. Simple enough. I wrote out 1025 records - just over 64K of data.
  806. Then I looked at the file with the QuickView Desk Accessory.
  807. The Hex Dump shows that the records look like this:
  808.  
  809. 0x00000000  0x01010101  0x02020202  0x03030303
  810. 0x04040404  0x05050505  0x06060606  0x07070707
  811. 0x08080808  0x09090909  0x0d0d0d0d  0x0b0b0b0b
  812.                         ^^^^^^^^^^ wrong!
  813. 0x0c0c0c0c  0x0d0d0d0d  0x0e0e0e0e  0x0f0f0f0f
  814.  
  815. Absolutely wrong!
  816.  
  817. So I wrote a second program in Think C. It fopens the binary
  818. file, freads 16 (4 byte) words at a time, and compares them with
  819. the pattern that I thought I had written out.
  820.  
  821. The output is the following:
  822.  
  823. ========== Start output =====================
  824. Error: Word 13 S/B 0d0d0d0d  IS 0a0a0a0a (also word 29, 45 etc..
  825.                                           i.e. every 0d0d0d0d word)
  826.  
  827. SHOULD BE:
  828. 0x00000000  0x01010101  0x02020202  0x03030303
  829. 0x04040404  0x05050505  0x06060606  0x07070707
  830. 0x08080808  0x09090909  0x0a0a0a0a  0x0b0b0b0b
  831. 0x0c0c0c0c  0x0d0d0d0d  0x0e0e0e0e  0x0f0f0f0f
  832.  
  833. ACTUAL
  834. 0x00000000  0x01010101  0x02020202  0x03030303
  835. 0x04040404  0x05050505  0x06060606  0x07070707
  836. 0x08080808  0x09090909  0x0a0a0a0a  0x0b0b0b0b
  837.                         ^^^^^^^^^^ -> not what Quickview saw!
  838. 0x0c0c0c0c  0x0a0a0a0a  0x0e0e0e0e  0x0f0f0f0f
  839.             ^^^^^^^^^^ -> where did this come from?
  840. ========== End output =====================
  841.  
  842. The Think Debugger believes that the data written out by the first program
  843. is correct (i.e. 0, 1, 2, 3...d, e, f at the call to fwrite). It also
  844. believes that word 13 of the second program is WRONG i.e. the file
  845. contains 0a0a0a0a where it should contain 0d0d0d0d. But word 10, which
  846. Quickview thinks contains 0d0d0d0d (incorrect) seems to contain
  847. 0a0a0a0a (correct) in the Think C program.
  848.  
  849. HELP!!!!! What is going on here?
  850.  
  851. Unless this is a major library problem, please respond
  852. directly to me. I'll send a summary if it seems appropriate
  853. (that means, if I didn't do something so stupid that I'm
  854. ashamed to ever see my name on the network again...  :)
  855.  
  856. Thanks in advance, source code (about 90 lines total) follows .sig
  857.  
  858. nbc
  859.  
  860. NAME:   Neil B. Cohen (Tracor Applied Sciences)
  861. PHONE:  703-444-4610
  862. DOMAIN: nbc@excalibur.itd.nrl.navy.mil
  863. *************************************************************
  864. * Murphy's Philosophy: Smile - tomorrow will be worse...    *
  865. *                                                           *
  866. * O'Tooles Commentary: Murphy was an optimist!              *
  867. *************************************************************
  868.  
  869. ======== write_binary.c ======
  870.  
  871. #include <stdio.h>
  872. #include <string.h>
  873.  
  874. FILE *Ofd;
  875. char *fname = "Binary.Dat";
  876.  
  877. long binvar[16] = { 0x00000000, 0x01010101, 0x02020202, 0x03030303,
  878.                     0x04040404, 0x05050505, 0x06060606, 0x07070707,
  879.                     0x08080808, 0x09090909, 0x0a0a0a0a, 0x0b0b0b0b,
  880.                     0x0c0c0c0c, 0x0d0d0d0d, 0x0e0e0e0e, 0x0f0f0f0f };
  881.  
  882. long Loop_count = 1025;
  883.  
  884. main(){
  885.     register int i;
  886.  
  887.     printf("Loop_count = %ld\n", Loop_count);
  888.  
  889.     Ofd = fopen(fname, "w");
  890.     if(Ofd == NULL){
  891.         printf("Failed to open %s\n", fname);
  892.         exit(1);
  893.     }
  894.  
  895.     for(i = 0; i < Loop_count; i++){
  896.         fwrite(&binvar[0], sizeof(binvar[0]), 16, Ofd);
  897.     }
  898. }
  899.  
  900. ======== read_binary.c ======
  901.  
  902. #include <stdio.h>
  903. #include <string.h>
  904.  
  905. FILE *Ifd;
  906.  
  907. char *ifname = "Binary.Dat";
  908.  
  909. long binary[16] = { 0x00000000, 0x01010101, 0x02020202, 0x03030303,
  910.                     0x04040404, 0x05050505, 0x06060606, 0x07070707,
  911.                     0x08080808, 0x09090909, 0x0a0a0a0a, 0x0b0b0b0b,
  912.                     0x0c0c0c0c, 0x0d0d0d0d, 0x0e0e0e0e, 0x0f0f0f0f };
  913.  
  914. long binary_input[16];
  915. long Loop_count = 1025;
  916. long Word_count;
  917.  
  918. main(){
  919.     register int i, j, k;
  920.     char string[20];
  921.  
  922.     printf("Loop_count = %ld\n", Loop_count);
  923.  
  924.     Ifd = fopen(ifname, "r");
  925.     if(Ifd == NULL){
  926.         printf("Failed to open %s\n", ifname);
  927.         exit(1);
  928.     }
  929.  
  930.     for(Word_count = 0, i = 0; i < Loop_count; i++){
  931.         fread(&binary_input[0], sizeof(binary_input[0]), 16, Ifd);
  932.         for(j = 0; j < 16; j++){
  933.             if(binary_input[j] != binary[j]){
  934.                 printf("Error: Word %ld S/B %lx   IS %lx\n",
  935.                         Word_count, binary[j], binary_input[j]);
  936.                 printf("SHOULD BE:\n");
  937.                 for(k = 0; k < 16; k++){
  938.                     printf("%8lx  ", binary[k]);
  939.                     if(k == 7)
  940.                         printf("\n");
  941.                 }
  942.                 printf("\nACTUAL:\n");
  943.                 for(k = 0; k < 16; k++){
  944.                     printf("%8lx  ", binary_input[k]);
  945.                     if(k == 7)
  946.                         printf("\n");
  947.                 }
  948.                 printf("\n\nContinue? ");
  949.                 gets(string);
  950.                 if(string[0] != 'y')
  951.                     exit(1);
  952.             }
  953.         }
  954.         Word_count++;
  955.     }
  956. }
  957. 
  958. 
  959. Path: ucivax!gateway
  960. From: cohen@excalibur.itd.nrl.navy.MIL (Neil Cohen)
  961. Subject: Problem w/fread and fwrite
  962. Message-ID: <9011212138.AA12704@constellation.arpa>
  963. Newsgroups: fa.think-c
  964. Lines: 21
  965. Date: 21 Nov 90 22:25:38 GMT
  966.  
  967. Regarding the two short programs I sent in earlier this afternoon,
  968.  
  969. My thanks to Mark Nagle who pointed out that I needed to open the file
  970. with fopen(name, "wb") to force binary mode.
  971.                    ^
  972.  
  973. Since I had just copied the program from my U*ix box, I had only
  974. used "w". Pgm works properly now.
  975.  
  976. Much obliged for the help,
  977.  
  978. nbc
  979.  
  980. NAME:   Neil B. Cohen (Tracor Applied Sciences)
  981. PHONE:  703-444-4610
  982. DOMAIN: nbc@excalibur.itd.nrl.navy.mil
  983. *************************************************************
  984. * Murphy's Philosophy: Smile - tomorrow will be worse...    *
  985. *                                                           *
  986. * O'Tooles Commentary: Murphy was an optimist!              *
  987. *************************************************************
  988. 
  989. 
  990. Path: ucivax!gateway
  991. From: cohen@excalibur.itd.nrl.navy.MIL (Neil Cohen)
  992. Subject: Fread/fwrite
  993. Message-ID: <9011220036.AA12812@constellation.arpa>
  994. Newsgroups: fa.think-c
  995. Lines: 5
  996. Date: 22 Nov 90 00:38:18 GMT
  997.  
  998. For the record - several different people responded telling me
  999. about the "wb" mode in fopen. Thanks to all for the very prompt
  1000. response.
  1001.  
  1002. nbc
  1003. 
  1004. 
  1005. Path: ucivax!gateway
  1006. From: ZEGERS%AMC.UVA.NL@cunyvm.cuny.edu ("Jan G. Zegers")
  1007. Subject: subscribe
  1008. Message-ID: <FE98CC25687F001D9E@AMC.UVA.NL>
  1009. Newsgroups: fa.think-c
  1010. X-VMS-To: THINK-C@ICS.UCI.EDU
  1011. Lines: 2
  1012. Date: 22 Nov 90 08:57:32 GMT
  1013. X-Envelope-to: THINK-C@ICS.UCI.EDU
  1014.  
  1015. subscribe zegers@amc.uva.nl
  1016.  
  1017. 
  1018. 
  1019. Path: ucivax!gateway
  1020. From: GFT_ROBERT@gsbvxb.uchicago.edu (opcode ranger)
  1021. Subject: Question regarding definition of LongDateTime
  1022. Message-ID: <901122184034.29002221@GSBACD.UCHICAGO.EDU>
  1023. Newsgroups: fa.think-c
  1024. Lines: 20
  1025. Date: 23 Nov 90 00:42:01 GMT
  1026. X-Vmsmail-To: @THINKC
  1027.  
  1028. In "ScriptMgr.h" LongDateTime is defined as
  1029.  
  1030.     typedef struct { long comp[2]; } LongDateTime;
  1031.  
  1032. but in the script manager guide from Apple it's defined as
  1033.  
  1034.     typedef comp LongDateTime;
  1035.  
  1036. Why the workaround to simulate a comp?  And for that matter, where is comp
  1037. actually defined?  I looked in "SANE.h" but couldn't find it there; in THINK
  1038. Pascal that's where it's defined (well, SANE.p actually :->).
  1039.  
  1040. Since this is a simple question, if you could mail me an answer it would
  1041. probably be best, so as not to clog up the list.
  1042.  
  1043. Thanks!
  1044.  
  1045. Robert
  1046.  
  1047. gft_robert@gsbacd.uchicago.edu
  1048. 
  1049. 
  1050. Path: ucivax!gateway
  1051. From: dmitri@bolvan.ph.utexas.edu (Dmitri Linde)
  1052. Subject: Think C browser?
  1053. Message-ID: <9011251713.AA10787@bolvan.ph.utexas.edu.ph.utexas.edu.>
  1054. Posted-Date: Sun, 25 Nov 90 11:13:18 CST
  1055. Newsgroups: fa.think-c
  1056. Lines: 8
  1057. Date: 25 Nov 90 17:23:17 GMT
  1058.  
  1059. Hi!
  1060.  
  1061.   I was told that there exists a class browser for Think C...
  1062. Anyone has it?
  1063.  
  1064.      Thanks,
  1065.  - Dmitri
  1066. dmitri@bolvan.ph.utexas.edu
  1067. 
  1068. 
  1069. Path: ucivax!gateway
  1070. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1071. Subject: Think C browser?
  1072. Message-ID: <9011261538.AA13553@chaos.cs.brandeis.edu>
  1073. In-Reply-To: Dmitri Linde's message of 25 Nov 90 17:23:17 GMT <9011251713.AA10787@bolvan.ph.utexas.edu.ph.utexas.edu.>
  1074. Newsgroups: fa.think-c
  1075. Lines: 20
  1076. Date: 26 Nov 90 15:42:31 GMT
  1077.  
  1078. The only class broswer that I'm aware of is the broswer that comes
  1079. with MacApp (formerly called Mouser, now called MacBrowse (tm)).  This
  1080. class browser works with Think C after you make two changes to your
  1081. sources:
  1082.  
  1083. (1) Add "#define class struct" to, say, <oops.h>.
  1084.  
  1085. (2) Change all object declarations to use "class" instead of "struct".
  1086.  
  1087. Now you can parse your Think C code as C++.  This works quite well,
  1088. I'm told.
  1089.  
  1090. I don't know if Apple is planning to distribute MacBrowse w/o MacApp,
  1091. although I believe it's on the ETO CD-ROM which APDA sells.
  1092.  
  1093.     -phil
  1094. ----
  1095.    Phil Shapiro                           Technical Support Analyst
  1096.    Language Products Group                     Symantec Corporation
  1097.         Internet: phils@chaos.cs.brandeis.edu
  1098. 
  1099. 
  1100. Path: ucivax!gateway
  1101. From: paco@neuromancer.sps.mot.COM (Paco Xander Nathan)
  1102. Subject: index
  1103. Message-ID: <9011261701.AA08386@neuromancer>
  1104. Newsgroups: fa.think-c
  1105. Lines: 1
  1106. Date: 26 Nov 90 17:40:04 GMT
  1107.  
  1108. index
  1109. 
  1110. 
  1111. Path: ucivax!gateway
  1112. From: jenlan@eos.arc.nasa.GOV (Jennifer S Lanham)
  1113. Subject: (none)
  1114. Message-ID: <9011272343.AA24477@eos.arc.nasa.gov>
  1115. Newsgroups: fa.think-c
  1116. Lines: 54
  1117. Date: 27 Nov 90 23:44:44 GMT
  1118.  
  1119. Hello,
  1120.  
  1121. I am using the the oop capabilities of ThinkC 4.0.2.
  1122. I have a link error which I cannot resolve. The message is
  1123. "undefined: aSubClassName::(aFileName.c)"
  1124.  
  1125. I have a file "RedObj.h" which has three class definitions:
  1126. #define _H_RedObj
  1127.  
  1128. #include "CObject.h" /*superclass*/
  1129.  
  1130. CL1 : CObject{
  1131. /*method and variable declarations/*
  1132. };
  1133.  
  1134.  
  1135. CL2 : CL1{
  1136. /*methods and variables declarations*/
  1137. };
  1138.  
  1139. CL3 : CL1{
  1140. /*methods and variable declarations*/
  1141. };
  1142.  
  1143. I have instances of each class declared in an xterns.h file
  1144. #include "RedObj.h"
  1145.  
  1146. extern CL1 *back;
  1147. extern CL2 *ring;
  1148. extern CL3 *target;
  1149.  
  1150. NOW,
  1151.  
  1152. In another file, I am initializing these instances...
  1153. #include "xterns.h"
  1154. #include "RedObj.h"
  1155. #include <oops.h>
  1156.  
  1157. back = new(CL1);
  1158. ring = new(CL2);
  1159. target = new(CL3);
  1160.  
  1161. The linker says that CL3 is undefined. The others are fine.
  1162. After checking the usual things like mispellings, missing block
  1163. terminators, I finally tried bizarre things like switching the order
  1164. of the original class declarations.
  1165.  
  1166. Any ideas as to the problem???
  1167.  
  1168. I have used this stuff since it came out in 4.0. I just don't understand
  1169. it!
  1170. Thank you for any ideas,
  1171. Jennifer
  1172. jenlan@eos.arc.nasa.gov
  1173. 
  1174. 
  1175. Path: ucivax!gateway
  1176. From: francis@csli.stanford.edu (Dave Francis)
  1177. Subject: floating point accuracy
  1178. Message-ID: <CMM.0.88.659825103.francis@csli.stanford.edu>
  1179. Newsgroups: fa.think-c
  1180. Lines: 28
  1181. Date: 28 Nov 90 20:47:53 GMT
  1182.  
  1183. Hello netters!
  1184.  
  1185. I have a roundoff problem when using floating point numbers in Think C 4.0.2.
  1186.  
  1187. I've written a function which takes a floating point number and returns
  1188. a string that can be used for displaying with QuickDraw.
  1189.  
  1190. The problem is that when I pass the value to be converted Think C changes
  1191. it to a less accurate number so when I generate the string I don't get exactly
  1192. what was passed in. Here's a example:
  1193.  
  1194. The number input is 2.314 but inside the routine it becomes 2.3139996765 or
  1195. something like that (I think becuase Think C passes floating point as
  1196. extended). Anyway when I generate the string the return is "2.313" if the
  1197. precision is set to 3 (the function also takes a precision parameter)
  1198. It gets worse if I pass a value which has less significant digits than the
  1199. precision. So the value 3.2 passed in with a precision parameter of 3
  1200. in some cases gets returned as "3.199", which is unexceptable for display
  1201. purposes if the user e ntered 3.2.
  1202.  
  1203. Is there a way to stop this loss of accuracy when passing floating point
  1204. values? Why is there  a loss of accuracy anyway? What should I do? Are
  1205. there any rounding functions out there or better float->string converters?
  1206.  
  1207.  
  1208. Help!!
  1209.  
  1210. Dave Francis  Sapphire Design Systems
  1211. 
  1212. 
  1213. Path: ucivax!gateway
  1214. From: emmayche@dhw68k.cts.COM (Mark Hartman)
  1215. Subject: Floating-point blues - Dave Francis
  1216. Message-ID: <9011290217.AA28573@dhw68k.cts.com>
  1217. Newsgroups: fa.think-c
  1218. Lines: 34
  1219. Date: 29 Nov 90 14:19:26 GMT
  1220.  
  1221. Dave Francis <francis@csli.stanford.edu> writes:
  1222.  
  1223. >I have a roundoff problem when using floating point numbers in Think C
  1224. >4.0.2.
  1225. >
  1226. >The problem is that when I pass the value to be converted Think C changes
  1227. >it to a less accurate number so when I generate the string I don't get exactly
  1228. >what was passed in. Here's a example:
  1229. >
  1230. >The number input is 2.314 but inside the routine it becomes 2.3139996765 or
  1231. >something like that (I think becuase Think C passes floating point as
  1232. >extended). Anyway when I generate the string the return is "2.313" if the
  1233. >precision is set to 3 (the function also takes a precision parameter)
  1234.  
  1235. This is a problem with any floating point number implementation on any
  1236. computer system, Dave.  There is no way to precisely express a non-integer
  1237. value using a floating-point system.
  1238.  
  1239. All solution sets to this problem that I know of require you to decide the
  1240. maximum number of places to the right of the decimal point which are usable
  1241. by your routine.  After you do this, the easiest solution is to add half
  1242. of the minimum expressable quantity you decided upon to the result (e.g. if
  1243. you decided that 3 places were all they got, add .0005 to the result) and
  1244. truncate at that point.
  1245.  
  1246. By the way, if posting replies this way is not the proper way to do it (if
  1247. one is supposed to reply only privately), please let me know... thanks.
  1248.  
  1249. Good luck.
  1250. ====
  1251. Mark Hartman, N6BMO           "What are you just standing there for?  Where
  1252. Applelink: N1083 or BINARY.TREE      do you think you are, DIS-ney World??"
  1253. Internet: emmayche@dhw68k.cts.com                -- General Knowledge, from
  1254. uucp: ...{spsd,zardoz,felix}!dhw68k!emmayche                CRANIUM COMMAND
  1255. 
  1256. 
  1257. Path: ucivax!gateway
  1258. From: ech@pegasus.att.COM
  1259. Subject: Re: floating point accuracy
  1260. Original-From: ech (Ned Horvath)
  1261. Lines: 89
  1262. Date: 29 Nov 90 19:24:15 GMT
  1263. Phone: (201) 576-3005
  1264. Message-ID: <9011291123.aa28068@ICS.UCI.EDU>
  1265. In-Reply-To: your message <internet3322334330> of Wed Nov 28 20:47:53 GMT 1990
  1266. >To: att!ics.uci.edu!think-c
  1267. Content-Type: Text
  1268. Content-Length: 3761
  1269. Newsgroups: fa.think-c
  1270. Message-Version: 2
  1271. Email-Version: 2
  1272. UA-Message-ID: <MAC-1.3.4A1-618034-ech-682>
  1273. UA-Content-ID: <PMX-PC-2.01A-000144-pegasus1-ech-2920>
  1274.  
  1275. ------------ Original Message -------------
  1276. Hello netters!
  1277.  
  1278. I have a roundoff problem when using floating point numbers in Think C
  1279. 4.0.2...
  1280.  
  1281. I've written a function which takes a floating point number and returns
  1282. a string that can be used for displaying with QuickDraw.
  1283. ...
  1284. Is there a way to stop this loss of accuracy when passing floating point
  1285. values? Why is there  a loss of accuracy anyway? What should I do? Are
  1286. there any rounding functions out there or better float->string converters?
  1287.  
  1288.  
  1289. Help!!
  1290.  
  1291. Dave Francis  Sapphire Design Systems
  1292. --------- End of Original Message ---------
  1293.  
  1294. Floating point numbers always experience SOME loss of accuracy: consider
  1295. expressing 1/3 as a decimal number: the sequence of threes is periodic, but
  1296. infinite, and so there's always a bit of loss.  In short, it ain't the Mac,
  1297. and it ain't SANE, and it ain't a ThC problem.
  1298.  
  1299. This can't turn into a numerical methods lecture (course, career, ...) but
  1300. suffice to say that some algorithms are much more sensitive ("unstable") to
  1301. rounding error than others, so depending on how you manipulate the numbers,
  1302. you can get good or bad results.  Look in the (book) library under numerical
  1303. analysis: authors like Foreman Acton and Webb Miller will help you find good
  1304. (i.e. less sensitive) algorithms.
  1305.  
  1306. At display time, use an old APL trick, the "fuzz."  Decide what level of
  1307. accuracy is important to you, then add a bit to your result (or subtract a bit
  1308. if the value is negative) to allow rounding in the right direction.  If you
  1309. expect answers like xx.xxx, add .0005 before using sprintf.
  1310.  
  1311. If you're dealing with numbers with limited accuracy (like currency, interest
  1312. rates correct to 3 places, etc.) then you might consider avoiding floating
  1313. point altogether, using a fixed-point scheme, i.e. holding your numbers as
  1314. (long?) integers with an implicit scale factor.  Not only will you have better
  1315. accuracy, you'll have much better performance.  The Mac Toolbox Utilities
  1316. support a particular flavor of fixed-point (Fixed) -- see IM 1-467 -- with the
  1317. binary-point in the middle of a 32-bit word.  To display one of these using
  1318. sprintf, and three digits to the right of the decimal point:
  1319.  
  1320.     Fixed val;
  1321. ...
  1322.     sprintf (buffer, "%d.%d",
  1323.         (int) (val >> 16),      /* integer part */
  1324.         FixRound (labs(val) * 1000) % 1000     /* decimal part */
  1325.     );
  1326.  
  1327. Using Fixed will still result in rounding error when you use FixRatio to
  1328. convert decimal to Fixed. An alternative approach, if you are dealing with a
  1329. fixed number of decimal digits, e.g. currency, is to hold an amount of money
  1330. as an integer in terms of thousandths-of-a-dollar.  Then, when you go to
  1331. display it, use something like
  1332.  
  1333.     typedef long Bucks;
  1334.     Bucks val;
  1335.  
  1336.     sprintf (buffer, "$%d.%d",
  1337.         val/1000,       /* dollars */
  1338.         val%1000/10);   /* cents */
  1339.  
  1340. Now, when you want to add such numbers, just do it.  To multiply, remember
  1341. that you have to renormalize: in this example, multiplying two of these
  1342. numbers gives us millionths of a dollar, so we have to post-divide by 1000 to
  1343. get back to thousandths:
  1344.     Bucks a, b;
  1345. ...
  1346.     a = (a*b)/1000;
  1347. or, to take a percentage, say 8.5 percent:
  1348.     b = (a*85)/1000;    /* 8.5% == .085 == 85/1000 */
  1349.  
  1350. The bottom line -- and it's not for everyone! -- is that if you think about
  1351. your problem a bit, and work a bit harder, you can get high accuracy AND high
  1352. speed by avoiding floating point.  If the round-up-before-display works for
  1353. you, and the performance is adequate for your target audience, then just
  1354. ignore all this stuff.
  1355.  
  1356. At the risk of being tarred and feathered, COBOL handles this kind of thing
  1357. really well...
  1358.  
  1359. =Ned Horvath=
  1360. ehorvath@attmail.com
  1361.  
  1362. Disclaimer: I haven't programmed COBOL since '71.  But I'd use it if I had the
  1363. right kind of problem...
  1364. 
  1365. 
  1366. Path: ucivax!gateway
  1367. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  1368. Subject: CPreferences
  1369. Message-ID: <27434.9011291502@subnode.lfcs.ed.ac.uk>
  1370. Newsgroups: fa.think-c
  1371. Lines: 13
  1372. Date: 29 Nov 90 19:34:56 GMT
  1373.  
  1374. I've just written a class (based on someone elses's code) for reading and
  1375. writing application preferences. It looks for (or creates) a folder called
  1376. Preferences in the System Folder, and file in that folder with the same
  1377. name as the application. When the object is created, it opens this file
  1378. automatically, and provides Get and Put operations on the resources (yup,
  1379. it's a resource file). Dispose() closes the file.
  1380.  
  1381. I copied all the HFS-specific stuff verbatim, so I've no idea how that part
  1382. of it works, by the way...
  1383.  
  1384. Anybody want a copy?
  1385.  
  1386. Nick.
  1387. 
  1388. 
  1389. Path: ucivax!gateway
  1390. From: consp21@bingvaxu.cc.binghamton.edu (Ken Hoover)
  1391. Subject: Re : CPreferences
  1392. Message-ID: <9011292311.AA17645@bingvaxu.cc.binghamton.edu>
  1393. X-Mailer: Elm [version 2.1 PL1]
  1394. Newsgroups: fa.think-c
  1395. Lines: 29
  1396. Date: 29 Nov 90 23:15:34 GMT
  1397.  
  1398.  
  1399.  
  1400. > I've just written a class (based on someone elses's code) for reading and
  1401. > writing application preferences.
  1402. > [...]
  1403. > Anybody want a copy?
  1404. >
  1405.  
  1406.   Yes!  Yes!  I've been needing something like this for a while.
  1407.  
  1408.   However, you didn't include an email address, so I had to reply to
  1409. the list to be sure you get this.  Sorry folks.
  1410.  
  1411. > Nick.
  1412. >
  1413.  
  1414.                           - Ken
  1415.  
  1416. --
  1417. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1418. Ken Hoover - Senior Consultant       "In the East there is a great tree-
  1419. consp21@bingvaxu.cc.binghamton.edu     structure that men call 'Corporate
  1420. Disclaimer : I claim dis...              Headquarters'..."
  1421.               dat is yours.                 - The Tao of Programming
  1422. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1423.  
  1424.  
  1425.  
  1426.  
  1427. 
  1428. 
  1429. Path: ucivax!gateway
  1430. From: nick@lfcs.edinburgh.ac.UK (Nick Rothwell)
  1431. Subject: CPreferences - oh-oh...
  1432. Message-ID: <28257.9011301050@subnode.lfcs.ed.ac.uk>
  1433. Newsgroups: fa.think-c
  1434. Lines: 10
  1435. Date: 30 Nov 90 11:13:21 GMT
  1436.  
  1437. Hmm, I thought this might happen... twenty requests for it. What should I
  1438. do? I don't have easy FTP access to the States (though I can do it if
  1439. necessary), so can I just email the thing to someone to have it put on a
  1440. THINK-C archive or something? If so, fine, otherwise I'll just stuff and
  1441. BinHex the thing and mail it directly to the list. So (aside to the list
  1442. moderator, I guess, whose name/address I've forgotten, sorry:) if I can
  1443. mail this stuff to you for an archive site, I'll do so, otherwise I'll just
  1444. mail it to the list.
  1445.  
  1446. Nick.
  1447. 
  1448. 
  1449. Path: ucivax!gateway
  1450. From: dmitri@bolvan.ph.utexas.edu (Dmitri Linde)
  1451. Subject: Easy way to make permanent and conditional break points
  1452. Message-ID: <9011301452.AA13438@bolvan.ph.utexas.edu.ph.utexas.edu.>
  1453. Posted-Date: Fri, 30 Nov 90 08:52:49 CST
  1454. Newsgroups: fa.think-c
  1455. Lines: 48
  1456. Date: 30 Nov 90 15:15:11 GMT
  1457.  
  1458. Hi!
  1459.  
  1460.   There is a feature in Think-c debugger that I don't like: It doesn't
  1461. remomber break points.(I don't think of easy way to do this since
  1462. code may change a lot)^C
  1463. (Interrupt -- one more to kill letter)
  1464. ^Cbolvan:3> mail think-c@ics.uci.edu
  1465. Subject: Easy way to make permanent and conditional break points
  1466. Hi!
  1467.  
  1468.   There is a feature in Think-c debugger that I don't like: It doesn't
  1469. remmember break points.(I don't think of easy way to do this since
  1470. code may change a lot). So, when I debug, I have to set the
  1471. same break points 100th time. Besides, there are conditional
  1472. break points, which are even worse...
  1473.  
  1474.   I found an undocumented(at least in the manual) function which will
  1475. help me.
  1476.  
  1477.       Debugger();
  1478.   It will bring up debugger.
  1479.  
  1480.   So, now I just have to insert this function in place, where I want
  1481. break point to be, and when it runs, it will function just like normal
  1482. break point.
  1483.  
  1484.   It does even better in case of conditional break points:
  1485. if(error) Debugger();  /* Let's look at some variables and see what's wrong*/
  1486.  
  1487.  
  1488. This useful function should be documented in next version of Think-c manual.
  1489. I found out about it by coincedence:
  1490. I typed:
  1491. void    Debugger(Str255 message)
  1492. {
  1493.   AddMessageToDebugWindow(message);
  1494. }
  1495.  
  1496.    Hope the above message does something useful...
  1497.  
  1498.   - Dmitri Linde
  1499. dmitri@bolvan.ph.utexas.edu
  1500.  
  1501. P.S.  Sometimes people post messages saying that they've made something
  1502. interest
  1503. ing, does anybody want a copy?  Of' course they di want a copy, just
  1504. post your file to think-c archive, by ftping to ics.uci.edu, and uploading
  1505. into /incoming, and posting a short message onto the think-c list.
  1506. 
  1507. 
  1508. Path: ucivax!gateway
  1509. From: dmac@eagle.mit.edu ("David S. McCormick")
  1510. Subject: disappearing pointers inside struct's
  1511. Message-ID: <9011301523.AA20416@EAGLE.MIT.EDU>
  1512. Newsgroups: fa.think-c
  1513. Lines: 62
  1514. Date: 30 Nov 90 15:25:50 GMT
  1515.  
  1516. I have had some trouble with the address of pointers (the value returned
  1517. by *thePointer) which are fields within strucs. To wit, I was writing an
  1518. ansi-type c program (i.e., no Toolbox calls) to do a numerical
  1519. simulation. The struct contained a few pointers to dynamically allcoated
  1520. arrays . It looked something like this:
  1521.  
  1522. typedef struct myStruct {
  1523.         int     someValue;
  1524.         double  anotherValue;
  1525.         ...
  1526.         double  *aVector;
  1527.         double  **anArray;
  1528. } MYSTRUCT, *MYSTRUCTPTR;
  1529.  
  1530. The structs were allocated as:
  1531.  
  1532. MYSTRUCTPTR     aStructPtr;
  1533. aStructPtr = (MYSTRUCTPTR) malloc( (unsigned) sizeof( MYSTRUCT ) );
  1534.  
  1535. The vectors in the struct were allocated normally (using malloc; method
  1536. of Press et al. "Numerical Recipies in C" Cambridge Univ Press.) and
  1537. values were put in them. When I passed a MYSTRUCTPTR to a subroutine,
  1538. after some steps in the subroutine, the addresses of the array pointers
  1539. would change to totally different addresses and the data pointed to
  1540. would no longer be the originally values. Everything thereafter was
  1541. garbage. What gives? I thought that malloc() really called NewPtr() and
  1542. therefore the memory should be non-relocatable. The stuff shouldn't
  1543. shift, should it? Should I have been passing the array pointers to the
  1544. subroutine instead of the struct pointer?
  1545. As I was under time pressure I got around it by not using the struct,
  1546. rather just declaring all the fields and arrays individually [like a
  1547. good FORTRAN program]. I also know that I can get around it by declaring
  1548. the struct globally (since the memory gets allocated on the stack
  1549. (right?), but I don't necessarily want to have global scope.
  1550. I ran the program on an SE/30 sys6.0.5, ThinkC 4.0.2.
  1551.  
  1552. As a side issue, does anyone out there who does numerical work know a
  1553. way to allocate arrays dynamically like Numerical Recipies but do it
  1554. with NewHandle instead of an implicit call to NewPtr via malloc? Is this
  1555. worth doing?
  1556. This is the Numerial Recipies flavor of dynamic array allocation (except
  1557. that I use calloc() instead of malloc() as they do. These methods have
  1558. proved bullet-proof for numerical work in ThinkC:
  1559.  
  1560. float *vector(int nl, int nh)
  1561. {
  1562. /*    allocates a float vector with range [nl...nh] */
  1563.     float    *v;
  1564.  
  1565.   v = (float *) calloc((unsigned) (nh-nl+1), (unsigned) sizeof(float));
  1566.      if (!v) nrerror("allocation failure in vector()");
  1567.      return v-nl;
  1568. }
  1569.  
  1570. I would really appreciate any help on these issues. Thanks
  1571.  
  1572. David S. McCormick
  1573. MIT Earth, Atmospheric and Plantary Sciences
  1574. Cambridge, MA
  1575.  
  1576. dmac@athena.mit.edu
  1577. dmac@eagle.mit.edu
  1578. 
  1579. 
  1580. Path: ucivax!gateway
  1581. From: cl29+@andrew.cmu.edu (Cameron Christopher Long)
  1582. Subject: Graf3D in ThinkC
  1583. Message-ID: <kbJcGC_00Vp10D10cz@andrew.cmu.edu>
  1584. Newsgroups: fa.think-c
  1585. Lines: 15
  1586. Date: 30 Nov 90 16:17:39 GMT
  1587.  
  1588. Hello,
  1589.  
  1590. I have recently become very interested in exploring the virtually
  1591. undocumented Graf3D routines. I have some simple MPW code for using
  1592. these routines, but am having trouble getting it to compile under ThinkC.
  1593.  
  1594. Does anyone know exactly what is required under ThinkC to access these
  1595. routines?
  1596.  
  1597. Thanks in advance,
  1598.  
  1599. Cameron Long
  1600.  
  1601.   Internet: cl29@andrew.cmu.edu
  1602. Applelink: d6788
  1603. 
  1604. 
  1605. Path: ucivax!gateway
  1606. From: kenk@sunHd.TELLABS.COM (Ken Konecki)
  1607. Subject: Re: Easy way to make permanent and conditional break points
  1608. Message-ID: <9011301828.AA27048@sunHd.TELLABS.COM>
  1609. In-Reply-To: <9011301452.AA13438@bolvan.ph.utexas.edu.ph.utexas.edu.>; from "Dmitri Linde" at Nov 30, 90 3:15 pm
  1610. X-Mailer: ELM [version 2.3 PL6]
  1611. Newsgroups: fa.think-c
  1612. Lines: 57
  1613. Date: 30 Nov 90 18:42:49 GMT
  1614.  
  1615. >
  1616. > Hi!
  1617. >
  1618. >   There is a feature in Think-c debugger that I don't like: It doesn't
  1619. > remomber break points.(I don't think of easy way to do this since
  1620. > code may change a lot)^C
  1621. > (Interrupt -- one more to kill letter)
  1622. > ^Cbolvan:3> mail think-c@ics.uci.edu
  1623. > Subject: Easy way to make permanent and conditional break points
  1624. > Hi!
  1625. >
  1626. >   There is a feature in Think-c debugger that I don't like: It doesn't
  1627. > remmember break points.(I don't think of easy way to do this since
  1628. > code may change a lot). So, when I debug, I have to set the
  1629. > same break points 100th time. Besides, there are conditional
  1630. > break points, which are even worse...
  1631. >
  1632. >   I found an undocumented(at least in the manual) function which will
  1633. > help me.
  1634. >
  1635. >       Debugger();
  1636. >   It will bring up debugger.
  1637. >
  1638. >   So, now I just have to insert this function in place, where I want
  1639. > break point to be, and when it runs, it will function just like normal
  1640. > break point.
  1641. >
  1642. >   It does even better in case of conditional break points:
  1643. > if(error) Debugger();  /* Let's look at some variables and see what's wrong*/
  1644. >
  1645. >
  1646. > This useful function should be documented in next version of Think-c manual.
  1647. > I found out about it by coincedence:
  1648. > I typed:
  1649. > void    Debugger(Str255 message)
  1650. > {
  1651. >   AddMessageToDebugWindow(message);
  1652. > }
  1653. >
  1654. >    Hope the above message does something useful...
  1655. >
  1656. >   - Dmitri Linde
  1657. > dmitri@bolvan.ph.utexas.edu
  1658. >
  1659. > P.S.  Sometimes people post messages saying that they've made something
  1660. > interest
  1661. > ing, does anybody want a copy?  Of' course they di want a copy, just
  1662. > post your file to think-c archive, by ftping to ics.uci.edu, and uploading
  1663. > into /incoming, and posting a short message onto the think-c list.
  1664. >
  1665.  
  1666.  
  1667. --
  1668. Ken Konecki
  1669. "Eat well, stay fit, and die anyway"
  1670. e-mail:kenk@tellabs.com    -or-    ...!uunet!tellab5!kenk
  1671. U.S. Mail: 1271 Portchester Circle, Carol Stream, IL 60188
  1672. 
  1673. 
  1674. Path: ucivax!gateway
  1675. From: kenk@sunHd.TELLABS.COM (Ken Konecki)
  1676. Subject: Re: Easy way to make permanent and conditional break points
  1677. Message-ID: <9011301830.AA27057@sunHd.TELLABS.COM>
  1678. In-Reply-To: <9011301452.AA13438@bolvan.ph.utexas.edu.ph.utexas.edu.>; from "Dmitri Linde" at Nov 30, 90 3:15 pm
  1679. X-Mailer: ELM [version 2.3 PL6]
  1680. Newsgroups: fa.think-c
  1681. Lines: 12
  1682. Date: 30 Nov 90 18:43:28 GMT
  1683.  
  1684.  
  1685. Ooops. Ignore that last message from me.
  1686.  
  1687. Won't the Debugger() call bring up Macsbugs if you have it installed?
  1688.  
  1689. Cheers,
  1690.     -Ken K
  1691. --
  1692. Ken Konecki
  1693. "Eat well, stay fit, and die anyway"
  1694. e-mail:kenk@tellabs.com    -or-    ...!uunet!tellab5!kenk
  1695. U.S. Mail: 1271 Portchester Circle, Carol Stream, IL 60188
  1696. 
  1697. 
  1698. Path: ucivax!gateway
  1699. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1700. Subject: Easy way to make permanent and conditional break points
  1701. Message-ID: <9011301923.AA21892@chaos.cs.brandeis.edu>
  1702. In-Reply-To: Dmitri Linde's message of 30 Nov 90 15:15:11 GMT <9011301452.AA13438@bolvan.ph.utexas.edu.ph.utexas.edu.>
  1703. Newsgroups: fa.think-c
  1704. Lines: 20
  1705. Date: 30 Nov 90 19:25:08 GMT
  1706.  
  1707. The Debugger() call is actually a toobox trap, number 0xA9FF.  It
  1708. isn't documented because ThC's manuals don't document any Macintosh
  1709. calls -- although an exception should be made in this case, I think.
  1710.  
  1711. You may also find the trap DebugStr (number 0xA9FE) useful.  Its
  1712. prototype is:
  1713.  
  1714. void DebugStr(Str255 msg);    /* msg is a Pascal-format string */
  1715.  
  1716. It will     display a message in the Think C source window and halts
  1717. program execution.
  1718.  
  1719. Note that these calls are supported by all debuggers, including
  1720. MacsBug and TMON.
  1721.  
  1722.     -phil
  1723. ----
  1724.    Phil Shapiro                           Technical Support Analyst
  1725.    Language Products Group                     Symantec Corporation
  1726.         Internet: phils@chaos.cs.brandeis.edu
  1727. 
  1728. 
  1729. Path: ucivax!gateway
  1730. From: hanche@imf.unit.no (Harald Hanche-Olsen)
  1731. Subject: disappearing pointers inside struct's
  1732. Message-ID: <9011301925.AA20264@hufsa>
  1733. In-Reply-To: "David S. McCormick"'s message of 30 Nov 90 15:25:50 GMT <9011301523.AA20416@EAGLE.MIT.EDU>
  1734. Newsgroups: fa.think-c
  1735. Lines: 18
  1736. Date: 30 Nov 90 19:30:37 GMT
  1737.  
  1738.    MYSTRUCTPTR     aStructPtr;
  1739.    aStructPtr = (MYSTRUCTPTR) malloc( (unsigned) sizeof( MYSTRUCT ) );
  1740.  
  1741. Hey wait a minute.  That malloc expects a size_t, which is long in
  1742. Think C.  sizeof() returns an int rather than size_t in Think, one of
  1743. those inconsistencies with ANSI C we all have grown to love.  So using
  1744. instead malloc((size_t)sizeof( MYSTRUCT )) ought to do the trick.
  1745.  
  1746. I will leave someone else to answer the other questions.  It's
  1747. impossible to tell whether using handles is worth the hazzle without
  1748. knowing your application, but if (like most of my programs) it just
  1749. allocates memory, plays with it and then exits, no it's not worth the
  1750. trouble.  My two cents' worth...
  1751.  
  1752. - Harald Hanche-Olsen <hanche@imf.unit.no>
  1753.   Division of Mathematical Sciences
  1754.   The Norwegian Institute of Technology
  1755.   N-7034 Trondheim, NORWAY
  1756. 
  1757. 
  1758. Path: ucivax!gateway
  1759. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1760. Subject: disappearing pointers inside struct's
  1761. Message-ID: <9011301936.AA24476@chaos.cs.brandeis.edu>
  1762. In-Reply-To: "David S. McCormick"'s message of 30 Nov 90 15:25:50 GMT <9011301523.AA20416@EAGLE.MIT.EDU>
  1763. Newsgroups: fa.think-c
  1764. Lines: 27
  1765. Date: 30 Nov 90 19:40:54 GMT
  1766.  
  1767. I can't tell from your posting what your problem is, but I can make
  1768. some suggestions.
  1769.  
  1770. For one, memory allocated using malloc()/calloc() is nonrelocatable.
  1771. It is essentially allocated using NewPtr(), and it will not move
  1772. during your program's execution.  The problems you're running into
  1773. sound more like memory being trounced (or perhaps improper memory
  1774. allocation).
  1775.  
  1776. Here's the standard rules of thumb:
  1777.  
  1778. Make sure you're including <stdlib.h> in every file where you use
  1779. malloc().
  1780.  
  1781. Make sure that you prototype *all* your functions (or at least, those
  1782. that return non-integral (eg. long or pointer) results).
  1783.  
  1784. Always cast the result of sizeof() to either size_t (ANSI programs) or
  1785. Size (Mac programs).
  1786.  
  1787. hope this helps,
  1788.  
  1789.     -phil
  1790. ----
  1791.    Phil Shapiro                           Technical Support Analyst
  1792.    Language Products Group                     Symantec Corporation
  1793.         Internet: phils@chaos.cs.brandeis.edu
  1794. 
  1795. 
  1796. Path: ucivax!gateway
  1797. From: gstein@us.oracle.COM (Greg Stein)
  1798. Subject: Re: disappearing pointers inside struct's
  1799. Message-ID: <9011301955.AA10240@hqsun4.us.oracle.com>
  1800. Newsgroups: fa.think-c
  1801. Lines: 37
  1802. Date: 30 Nov 90 20:01:38 GMT
  1803.  
  1804. > From: "David S. McCormick" <dmac@eagle.mit.edu>
  1805. >
  1806. > typedef struct myStruct {
  1807. >         ...
  1808. >         double  *aVector;
  1809. >         double  **anArray;
  1810. > } MYSTRUCT, *MYSTRUCTPTR;
  1811. >
  1812. > [portions ommitted ]
  1813. >
  1814. > The vectors in the struct were allocated normally (using malloc; method
  1815. > of Press et al. "Numerical Recipies in C" Cambridge Univ Press.) and
  1816. > values were put in them. When I passed a MYSTRUCTPTR to a subroutine,
  1817. > after some steps in the subroutine, the addresses of the array pointers
  1818. > would change to totally different addresses and the data pointed to
  1819. > would no longer be the originally values. Everything thereafter was
  1820. > garbage. What gives? I thought that malloc() really called NewPtr() and
  1821. > therefore the memory should be non-relocatable. The stuff shouldn't
  1822. > shift, should it? Should I have been passing the array pointers to the
  1823. > subroutine instead of the struct pointer?
  1824.  
  1825. David,
  1826.  
  1827. The memory probably is non-relocatable.  You appear to be doing
  1828. everything correctly, but you did not provide information on how you
  1829. allocated aVector and anArray.  Particularly, anArray.  If you could
  1830. provide your method of allocating that, we might be able to solve your
  1831. problem.
  1832.  
  1833. Typically, many people forget the "double **anArray" is actually a
  1834. pointer to a vector of pointers to vectors of doubles.  If you don't
  1835. allocate anArray in this arrangement, you could probably see results
  1836. like yours (where things seem to mysteriously get trashed).
  1837.  
  1838. Greg Stein
  1839. Arpa: gstein%oracle.uucp@apple.com
  1840. UUCP: ..!{uunet,apple}!oracle!gstein
  1841. 
  1842.